package org.restly.doc;

import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.FieldDoc;
import com.sun.javadoc.MethodDoc;
import com.sun.javadoc.Tag;
import org.restly.core.ResourceInfo;

import java.util.List;

/**
 * Nov 29, 2008, 4:32:33 AM
 *
 * @author <a href="mailto:erik.beeson@gmail.com">Erik Beeson</a>
 */
public class ResourceDoc {
	public ResourceDoc(String path, ClassDoc classDoc) {
		for(FieldDoc fieldDoc : classDoc.fields(false)) {
			List<String> attributeNames = ResourceInfo.parseAttributeNames(path);
			if(fieldDoc.isPublic()) {
				System.out.println(fieldDoc.name() + " (parameter): " + fieldDoc.commentText());
			} else if(attributeNames.contains(fieldDoc.name())) {
				System.out.println(fieldDoc.name() + " (path): " + fieldDoc.commentText());
			}
		}
		for(MethodDoc methodDoc : classDoc.methods()) {
			if(!methodDoc.isConstructor() && methodDoc.isPublic()) {
				System.out.println(methodDoc.name().toUpperCase() + ": " + methodDoc.commentText());
				for(Tag tag : methodDoc.tags("@return")) {
					System.out.println("Return: " + tag.text());
				}
			}
		}
	}
}
